#pragma once




namespace boost
{
	/**
	 * This predicate is meant to be used as the equality predicate for a boost::unordered_set / map.
	 */
	template <typename T>
	bool operator==(weak_ptr<T> const &a, weak_ptr<T> const & b)
	{
		return !a._internal_less(b) && !b._internal_less(a);
	}
	///////////////////////////////////////////////////////////////////////////////////////////////

	template<class T> std::size_t hash_value(weak_ptr<T> const & a)
	{
		static_assert(sizeof(std::size_t) == sizeof(T*), "std::size_t must have the same size as a pointer");
		static_assert(sizeof(weak_ptr<T>) == 2 * sizeof(void*), "Check this hack, the size of weak_ptr has been changed, since the initial implementation");

		// Awesome... offsetof cannot acces a private member, therefore I cannot guarantuee that this will even work
		const T* px = reinterpret_cast<const T*>(*reinterpret_cast<const std::size_t*>(&a));

		// Well, you can see in the debugger that both a.px and px have the same value :-)
		return hash_value(px);
	}
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
